package logic

import (
	"context"
	"home-manage/homerpc/homerpc"

	"home-manage/api/internal/svc"
	"home-manage/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ConsultationAddLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewConsultationAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ConsultationAddLogic {
	return &ConsultationAddLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ConsultationAddLogic) ConsultationAdd(req *types.ConsultationAddRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	add, err := l.svcCtx.HomeRpc.ConsultationAdd(l.ctx, &homerpc.ConsultationAddRequest{
		UserId:  req.UserId,
		HouseId: req.HouseId,
		Content: req.Content,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Data:    nil,
			Code:    0,
		}, nil
	}
	return &types.Response{
		Message: "咨询成功",
		Data:    add,
		Code:    200,
	}, nil
}
